<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8" />
  <title>AJAX的实现判断用户名是否存在</title>
  <style type="text/css">
  	body{background-image:url(img/bk.jpg)}
  </style>
  <script src="js/jquery.min.js"></script> 
 </head>
 <body>
  <div>  
   姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名:
   <input type="text" id="name" />
   <span></span>   
  </div>
  <div>
   密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:<input type="password" />   
  </div>
  <div>
   确认密码:<input type="password" />   
  </div>
  <div>
   手&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;机:<input type="text"/>   
  </div>
  <div>
   <button type="button">提交</button>   
  </div>  
 </body>
</html>
<script>
    $("#name").blur(function(){
     $.ajax({
      method:"get",
      url:"http://127.0.0.1:4523/m2/2787759-0-default/84859825",
      data:{name:$("#name").val()},
      dataType:"text",
      success:function(r){
       if(r=="has"){
        $("#name+span").html("×").css({"color":"#f00"});
       }else{
        $("#name+span").html("√").css({"color":"#48b840"});
       }
	   
       // 219970107 胡毅
	   
      },
     });
    });
   </script>